<template>
  <div>
    <el-form :model="formInline" label-width="80px">
      <el-form-item label="菜单名称">
        <el-input v-model.trim="formInline.Name" placeholder="菜单名称" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="菜单地址">
        <el-input v-model="formInline.Url" placeholder="菜单地址" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="授权码">
        <el-input v-model="formInline.CustomData" placeholder="授权码" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="菜单图标">
        <el-input v-model="formInline.Icon" placeholder="菜单图标" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="菜单类名">
        <el-input v-model="formInline.ClassName" placeholder="菜单类名" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="菜单上级">
        <el-select v-model="formInline.ParentId" clearable placeholder="请选择" :disabled="true">
          <el-option
            v-for="item in parentMenuList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="排序">
        <el-input v-model.number="formInline.Sort" placeholder="排序" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item class="viewdata_button">
        <el-button type="default" @click="ViewCancle">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import {mixinDetailMixed} from '@/mixedObject/detailMixed';
export default {
  mixins:[mixinDetailMixed],
  props: ["currentId", "random"],
  data() {
    return {
     
     parentMenuList:[],
    };
  },
  watch: {
    random(newValue, oldValue) {
      //初始化表单
      this.InitFormInLine();
    }
  },
  created() {
       //初始化表单
      this.InitFormInLine();
    //初始化上级菜单数据
    this.InitParentMenuList() 
  },
  methods: {
    //初始化
    InitFormInLine() {
       this.$store
        .dispatch("menu/GetMenuInfo", { Id: this.currentId })
        .then(data => {
          this.formInline = {
            Id: this.currentId,
            Name: data.name,
            Url: data.url,
            CustomData: data.customData,
            Icon: data.icon,
            ClassName: data.className,
            ParentId: data.parentId,
            Sort: data.sort,
            TypeOper: "1"
          };
        });
    },
     //初始化上级菜单数据
    InitParentMenuList() {
      this.$store
        .dispatch("menu/GetMenuInfoList", { PageIndex: 1, PageSize: 99999 })
        .then(data => {
          data.listData.forEach(element => {
            this.parentMenuList.push({
              value: element.id,
              label: element.name
            });
          });
        });
    },
  }
};
</script>